# encoding: utf-8

class Reply < ActiveRecord::Base
  belongs_to  :author,
              :class_name => "User",
              :foreign_key => "user_id"
  
  belongs_to  :topic,
              :touch  =>  true

  #Validations
  validates :user_id,
            :presence     =>  true,
            :numericality =>  { :only_integer =>  true,
                                :greater_than =>  0  }

  validates :topic_id,
            :presence     =>  true,
            :numericality =>  { :only_integer =>  true,
                                :greater_than =>  0  }

  validates :description, :presence => true
  validates :description, :length   => { :within => 5..5000 }, :unless => "self.description.empty?"
end

# == Schema Information
#
# Table name: replies
#
#  id          :integer         not null, primary key
#  topic_id    :integer
#  user_id     :integer
#  description :text
#  created_at  :datetime
#  updated_at  :datetime
#

